package com.ms.demo;

import com.ms.demo.advance.AdvancedMediaPlayer;
import com.ms.demo.advance.Mp4Player;
import com.ms.demo.advance.VlcPlayer;

/**
 * @description: 创建媒体播放器的适配器类  用来适配高级媒体播放器
 * @author: ms
 * @create: 2022-10-24 11:01
 */
public class MediaAdapter implements MediaPlayer {

    //注入高级媒体播放器
    AdvancedMediaPlayer advancedMusicPlayer;

    public MediaAdapter(String audioType){
        if(audioType.equalsIgnoreCase("vlc") ){
            advancedMusicPlayer = new VlcPlayer();
        } else if (audioType.equalsIgnoreCase("mp4")){
            advancedMusicPlayer = new Mp4Player();
        }
    }

    @Override
    public void play(String audioType, String fileName) {
        if(audioType.equalsIgnoreCase("vlc")){
            advancedMusicPlayer.playVlc(fileName);
        }else if(audioType.equalsIgnoreCase("mp4")){
            advancedMusicPlayer.playMp4(fileName);
        }
    }
}